home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 24 / CU Amiga Magazine's Super CD-ROM 24 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-07].iso / Scalos / RenderLib / doc / texture < prev    next >
Text File  |  1997-10-05  |  6KB  |  154 lines

  1.  
  2. texture-mapping
  3. ------------------------------
  4.   
  5.   first of all, texture-mapping is considered low-level. this
  6.   means it is implemented for maximum performance, at the cost of
  7.   accuracy. no interpolation takes place yet, but it is very fast.
  8.   it's mainly intended for realtime applications.
  9.   
  10.   for maximum performance, your source array (the texture buffer)
  11.   should be 2^n pixels wide, with n a positive integer greater 1.
  12.   if this condition is not met, performance drops significantly on
  13.   processors prior to the 68060, since an integer multiplication
  14.   for each pixel cannot be avoided in this case.
  15.   
  16.   inside render.library, texture-mapping is implemented via
  17.   scaling-engines. the term 'scaling-engine' might be confusing at
  18.   first sight. it's used for a generalized concept of low-level
  19.   conversion units that do some kind of stream conversion from an
  20.   input to an output buffer. scaling-engines may be passed to the
  21.   following functions: ScaleA(), RenderA(), ConvertChunkyA(). more
  22.   functions are yet to come. a plain conversion is performed via
  23.   ScaleA().
  24.   
  25.   there are three kinds of data required for texture-mapping: a
  26.   source buffer, a destination buffer, and an array of destination
  27.   coordinates. the destination coordinates form a trapezoid inside
  28.   the destination buffer.
  29.   
  30.   source buffer (S)
  31.   destination buffer (D)
  32.   destination trapezoid (T)
  33.  
  34.  
  35.                                           a'
  36.                                         /\  
  37.                                        /  \
  38.    a               b                  /    \
  39.      _____________            _______/______\__________
  40.     |             |          |      /        \         |
  41.     |             |          |     /          \        |
  42.     |      S      |          |    /            \   D   |
  43.     |             |          |   /              \      |
  44.     |_____________|          | d'\               \     |
  45.   d                 c        |    \        T      \    |
  46.                              |     \               \   |
  47.            |                 |      \               \  |
  48.            |                 |       \               \ |
  49.            |__________\      |        \               \|
  50.                       /      |         \               \
  51.                              |__________\______________|\
  52.                                          \               \
  53.                                        c' \_______________\ b'
  54.  
  55.  
  56.   the pixels inside the source array (S) are mapped to the
  57.   destination trapezoid (T). border clipping is fully implemented
  58.   - your destination trapezoid may even reside outside the
  59.   destination array. pixels are written only into that area where
  60.   D and T overlap.
  61.   
  62.   since texture-mapping is considered low-level, render.library
  63.   does not offer any 3d-routines for calculating the trapezoid's
  64.   coordinates. your job is to do the brain-work, render.library
  65.   only provides horsepower for the brute-force data transfers.
  66.  
  67.  
  68.  
  69. implementation
  70. ------------------------------
  71.  
  72.   set up a scaling-engine for texture-mapping:
  73.  
  74.     engine = CreateScaleEngine(
  75.                      sourcewidth, sourceheight,
  76.                      destwidth, destheight,
  77.                      RND_DestCoordinates, &coords,
  78.                      RND_PixelFormat, PIXFMT_CHUNKY_CLUT,
  79.                      TAG_DONE );
  80.  
  81.   currently, render.library allows two types of data processed
  82.   with scaling-engines: chunky bytes and truecolor longwords.
  83.   note: texture-mapping with truecolor data is not significantly
  84.   slower than with chunky pixels.
  85.  
  86.   
  87.   do texture-mapping:
  88.  
  89.     Scale(engine, sourcebuffer, destbuffer, NULL);
  90.  
  91.  
  92.   remove the scaling-engine:
  93.    
  94.     DeleteScaleEngine(engine);
  95.  
  96.  
  97.  
  98. specifying offsets
  99. ------------------------------
  100.  
  101.   ScaleA() allows additional tags for the total widths of the
  102.   source and destination buffers.
  103.  
  104.     RND_SourceWidth
  105.         total width of the source buffer [pixels].
  106.         Default: the scaling-engine's source width.
  107.  
  108.     RND_DestWidth
  109.         total width of the destination buffer [pixels].
  110.         Default: the scaling-engine's destination width.
  111.  
  112.   Let's apply these additional tags to the diagram:
  113.  
  114.                                           a'
  115.                                         /\  
  116.                                        /  \
  117.    a               b                  /    \
  118.      _____________            _______/______\__________ ________
  119.     |        |....|          |      /        \         |........|
  120.     |        |....|          |     /          \        |........|
  121.     |    S   |....|          |    /            \   D   |........|
  122.     |        |....|          |   /              \      |........|
  123.     |________|____|          | d'\               \     |........|
  124.   d                 c        |    \        T      \    |........|
  125.      <------>                |     \               \   |........|
  126.         sourcewidth¹         |      \               \  |........|
  127.                              |       \               \ |........|
  128.      <----------->           |        \               \|........|
  129.         RND_SourceWidth²     |         \               \........|
  130.                              |__________\______________|\_______|
  131.                                          \               \
  132.                                        c' \_______________\ b'
  133.  
  134.                               <----------------------->
  135.                                   destwidth¹
  136.                               
  137.                               <-------------------------------->
  138.                                   RND_DestWidth²
  139.  
  140.   ¹ passed to CreateScaleEngine()
  141.   ² passed to Scale(), Render(), ConvertChunky(), ...
  142.   
  143.   there are some details to be mentioned when offsets are
  144.   specified.
  145.   
  146.   1. the 2^n code optimization applies to the total width of the
  147.   source buffer. if you specify a sourcewidth of 256 pixels for
  148.   CreateScaleEngine(), but RND_SourceWidth is 300, you won't
  149.   profit from the optimized code.
  150.   
  151.   2. in the destination buffer, the right border is still clipped
  152.   at the column defined throughout destwidth. there are no pixels
  153.   written to the modulo area.
  154.